#include "rclcpp/rclcpp.hpp"
#include "base_interfaces_demo/srv/add_ints.hpp"


using base_interfaces_demo::srv::AddInts;

using std::placeholders::_1;
using std::placeholders::_2;

class MyServer:public rclcpp::Node{
    public:
    MyServer():Node("myserver")
    {
        server = this->create_service<AddInts>("Add",std::bind(&MyServer::add,this,_1,_2));
    }
    private:
    rclcpp::Service<AddInts>::SharedPtr server;
    void add(const AddInts::Request::SharedPtr req,const AddInts::Response::SharedPtr res){
        res->sum = req->num1 + req->num2;
        RCLCPP_INFO(this->get_logger(),"req:%d %d -- res:%d",req->num1,req->num2,res->sum);
    }

};

int main(int args,char** argv)
{
    rclcpp::init(args,argv);
    rclcpp::spin(std::make_shared<MyServer>());
    rclcpp::shutdown();
    return 0;
}



